package abstractfactory;

import abstractfactory.factory.Factory;
import abstractfactory.factory.impl.SqlServerFactoryImpl;
import abstractfactory.pojo.Department;
import abstractfactory.pojo.User;
import abstractfactory.service.DepartmentService;
import abstractfactory.service.UserService;

public class Application {
    //    public static void main(String[] args) {
//        User user = new User();
//        UserService userService = new UserServiceImpl();
//
//        userService.insert(user);
//
//        userService.getUser(1);
//
//        System.out.println();
//    }
//    public static void main(String[] args) {
//        User user = new User();
//        Factory factory = new AccessFactoryImpl();
//
//
//        UserService accessUser = factory.createUser();
//        accessUser.insert(user);
//        accessUser.getUser(1);
//
//        System.out.println("-------------------");
//    }
    public static void main(String[] args) throws Exception {
        Factory factory = new SqlServerFactoryImpl();
        UserService sqlServerUserService = factory.createUser();
        User user1 = new User();
        user1.setId(1);
        user1.setUsername("胡欢");
        sqlServerUserService.insert(user1);
        sqlServerUserService.getUser(1);


        DepartmentService departmentService = factory.createDepartment();
        Department department = new Department();
        department.setId(1);
        department.setDepartmentName("研发部");
        departmentService.insert(department);
        departmentService.getDepartment(1);
    }
}
